In a moving image encoding system represented by ITU-T H.264, an entire screen is divided into an encoding unit called a macroblock of 16 pixels×16 pixels to perform encoding.
In H.264, for an encoding target macroblock, a predicted value of a pixel value in the encoding target macroblock is determined using peripheral pixels and preceding and following pictures and a predicted error between encoding target pixels and the predicted value is entropy-encoded.
When the pixel value in the macroblock is predicted, intra-prediction for predicting the pixel value from the peripheral pixels and inter-prediction for predicting the pixel value from pixels of preceding and following pictures can be selected for each of macroblocks according to patterns in the macroblocks. The macroblock can be divided into prediction blocks smaller than 16 pixels×16 pixels to perform prediction. For example, as shown in FIG. 2, in the intra-prediction of H.264, the macroblock of 16 pixels×16 pixels is divided into sixteen prediction blocks of 4 pixels×4 pixels and peripheral pixels are copied to each of the prediction blocks in nine kinds of directions indicated by indexes 0 to 8 shown in FIG. 2, whereby pixels in the prediction blocks can be predicted.
As shown in FIG. 3, the macroblock is not divided and, in a prediction block of 16 pixels×16 pixels, peripheral pixels are copied in four kinds of directions indicated by indexes 0 to 3 shown in FIG. 3, whereby pixels in the prediction block can be predicted.
Concerning the inter-prediction of H.264, similarly, in the macroblock, the macroblock can be divided into smaller prediction blocks and motion vectors can be set for each of the prediction blocks. For example, as shown in FIG. 4, when a motion from a picture in the past is predicted, the macroblock can be divided into prediction blocks of 16 pixels×16 pixels, 16 pixels×8 pixels, 8 pixels×16 pixels, and 8 pixels×8 pixels (in this case, each of the prediction blocks can be further divided into 8 pixels×4 pixels, 4 pixels×8 pixels, and 4 pixels×4 pixels) and motion vectors different from one another can be set for the prediction blocks.
As explained above, the inside of the macroblock is divided into the prediction blocks and prediction is performed for each of the prediction blocks. Consequently, prediction accuracy is improved, for example, when a boundary of different patterns is present in the macroblock, leading to improvement of a compression ratio.
However, in the related art represented by H.264, the size of the macroblock is limited to a size equal to or smaller than 16 pixels×16 pixels. Prediction cannot be performed in a unit of a size larger than 16 pixels×16 pixels.
The selection of the intra-prediction or the inter-prediction can be set only in a macroblock unit. Therefore, the intra-prediction and the inter-prediction cannot be selected in a unit smaller than 16 pixels×16 pixels.
Therefore, in recent years, a technique for giving flexibility to the size itself of the macroblock and setting prediction blocks in a unit of a size larger than or smaller than 16 pixels×16 pixels has been disclosed (PTL 1 and NPL 1).